package com.woniuxy.house.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.entity.house.SecondhouseComment;
import com.woniuxy.house.mapper.SecondhouseCommentMapper;
import com.woniuxy.house.service.SecondhouseCommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author liangyu
 * @since 2021-03-19
 */
@Service
public class SecondhouseCommentServiceImpl extends ServiceImpl<SecondhouseCommentMapper, SecondhouseComment> implements SecondhouseCommentService {

    @Resource
    private SecondhouseCommentMapper secondhouseCommentMapper;

    // 根据二手房id查询评论
    @Override
    public Page<SecondhouseComment> findCommentsBySId(int sid,int current,int size) {
        QueryWrapper<SecondhouseComment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("sid",sid);
        return secondhouseCommentMapper.selectPage(new Page<>(current,size),queryWrapper);
    }

    // 根据二手房id查询评论
    @Override
    public Page<SecondhouseComment> findCommentsByBId(int bid,int current,int size) {
        QueryWrapper<SecondhouseComment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("bid",bid);
        return secondhouseCommentMapper.selectPage(new Page<>(current,size),queryWrapper);
    }

    // 根据id软删除评论
    @Override
    public boolean deleteOneById(int id) {
        return secondhouseCommentMapper.deleteOneById(id) > 0;
    }

}
